//
//  aboutMeViewController.m
//  day1
//
//  Created by 于跃隆 on 2020/4/8.
//  Copyright © 2020 于跃隆. All rights reserved.
//

#import "aboutMeViewController.h"
#import "XyViewController.h"
#import "YSViewController.h"

@interface aboutMeViewController ()

@end

@implementation aboutMeViewController

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    
    self.navigationController.navigationBar.hidden = YES;
    
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self setNavContorlFrame];
    self.navigationController.navigationBar.hidden = NO;
}
-(void)setNavContorlFrame{
    //设置导航条颜色
        UIView *Jbview = [[UIView alloc] init];
        Jbview.userInteractionEnabled = YES;
    //    Jbview.frame = CGRectMake(0,KSCHEIGHT(-37),kSCRATIO(self.view.frame.size.width),KSCHEIGHT(75));

        CAGradientLayer *gl = [CAGradientLayer layer];
        gl.frame = CGRectMake(0,KSCHEIGHT(0),kSCRATIO(self.view.frame.size.width),KSCHEIGHT(82));
        gl.startPoint = CGPointMake(0, 0);
        gl.endPoint = CGPointMake(1, 1);
        gl.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:65/255.0 blue:91/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:171/255.0 blue:102/255.0 alpha:1.0].CGColor];
        gl.locations = @[@(0.0),@(1.0)];
        [Jbview.layer addSublayer:gl];
        
        [self.navigationController.navigationBar addSubview:Jbview];
        
        //返回button
        UIButton *backBtn = [[UIButton alloc] init];
        [backBtn setBackgroundImage:[UIImage imageNamed:@"backButton"] forState:UIControlStateNormal];
        [backBtn addTarget:self action:@selector(BackClick) forControlEvents:UIControlEventTouchUpInside];
        [Jbview addSubview:backBtn];
        
        //标题文字
        UILabel *navtitle = [[UILabel alloc] init];
        navtitle.text = @"关于我们";
        navtitle.textColor = [UIColor whiteColor];
        navtitle.font = kFONT(18);
        [Jbview addSubview:navtitle];
        
        [Jbview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(KSCHEIGHT(-37));
            make.width.mas_equalTo(kSCRATIO(self.view.frame.size.width));
            make.height.mas_equalTo(KSCHEIGHT(82));
        }];
        [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(Jbview.mas_left).mas_equalTo(kSCRATIO(20));
            make.bottom.mas_equalTo(Jbview.bottom).mas_equalTo(KSCHEIGHT(-15));
            make.width.mas_equalTo(kSCRATIO(10));
            make.height.mas_equalTo(KSCHEIGHT(18));
        }];
        [navtitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(Jbview);
            make.bottom.mas_equalTo(Jbview.bottom).mas_equalTo(KSCHEIGHT(-12));
            
        }];
}

-(void)BackClick{
    [self.navigationController popViewControllerAnimated:NO];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationItem setHidesBackButton:YES];
    [self.navigationController.navigationItem setHidesBackButton:YES];
    [self.navigationController.navigationBar.backItem setHidesBackButton:YES];
    
    [self.view removeAllSubviews];
    
    //245 246 251
    self.view.backgroundColor = [UIColor colorWithRed:245/255.0 green:246/255.0 blue:251/255.0 alpha:1.0];
    
    [self setContrFrame];
    
}
-(void)setContrFrame{
    UIView *Tview = [[UIView alloc] init];
    Tview.frame = CGRectMake(130,144,115,115);
    Tview.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    Tview.layer.shadowColor = [UIColor colorWithRed:173/255.0 green:172/255.0 blue:172/255.0 alpha:0.14].CGColor;
    ViewRadius(Tview, KSCHEIGHT(57.5));
    Tview.layer.shadowOffset = CGSizeMake(0,2);
    Tview.layer.shadowOpacity = 1;
    Tview.layer.shadowRadius = 4;
    [self.view addSubview:Tview];
    
    [Tview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view.mas_top).mas_equalTo(KSCHEIGHT(100));
        make.width.height.mas_equalTo(kSCRATIO(115));
    }];
    
    UILabel *banBlabel = [[UILabel alloc] init];
    banBlabel.frame = CGRectMake(170,284,35,14.5);
    banBlabel.numberOfLines = 0;
    
    NSMutableAttributedString *banBstring = [[NSMutableAttributedString alloc] initWithString:@"V3.0" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Semibold" size: 18],NSForegroundColorAttributeName: [UIColor colorWithRed:248/255.0 green:80/255.0 blue:92/255.0 alpha:1.0]}];

    banBlabel.attributedText = banBstring;
    
    [self.view addSubview:banBlabel];

    [banBlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(Tview.mas_bottom).mas_equalTo(KSCHEIGHT(20));
        
    }];
    
    //服务协议btn
    UILabel *xieyilabel = [[UILabel alloc] init];
    xieyilabel.numberOfLines = 0;

    NSMutableAttributedString *xieyistring = [[NSMutableAttributedString alloc] initWithString:@"服务协议" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: KSCHEIGHT(15)],NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]}];

    xieyilabel.attributedText = xieyistring;
    
    UIButton *xieyiBtn = [[UIButton alloc] init];
    xieyiBtn.backgroundColor = [UIColor colorWithRed:172/255.0 green:95/255.0 blue:251/255.0 alpha:1.0];
    xieyiBtn.layer.shadowColor = [UIColor colorWithRed:173/255.0 green:172/255.0 blue:172/255.0 alpha:0.14].CGColor;
    xieyiBtn.layer.shadowOffset = CGSizeMake(0,2);
    xieyiBtn.layer.shadowOpacity = 1;
    xieyiBtn.layer.shadowRadius = 4;

    [xieyiBtn addTarget:self action:@selector(xieyiBClick) forControlEvents:UIControlEventTouchUpInside];
    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = CGRectMake(0,0,kSCRATIO(250),KSCHEIGHT(40));
    gl.startPoint = CGPointMake(0, 0);
    gl.endPoint = CGPointMake(1, 1);
    gl.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:65/255.0 blue:91/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:171/255.0 blue:102/255.0 alpha:1.0].CGColor];
    gl.locations = @[@(0.0),@(1.0)];
    ViewRadius(xieyiBtn, KSCHEIGHT(20));

    [xieyiBtn.layer addSublayer:gl];
    [xieyiBtn addSubview:xieyilabel];
    [self.view addSubview:xieyiBtn];
    
    [xieyiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(banBlabel.mas_bottom).mas_equalTo(KSCHEIGHT(30));
        make.width.mas_equalTo(kSCRATIO(250));
        make.height.mas_equalTo(KSCHEIGHT(40));
        
    }];
    [xieyilabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(xieyiBtn);
        make.centerY.mas_equalTo(xieyiBtn);
    }];
    
    
    //iOS账号登录
    UILabel *yinsilabel = [[UILabel alloc] init];
    yinsilabel.frame = CGRectMake(150,372,75,14);
    yinsilabel.numberOfLines = 0;

    NSMutableAttributedString *yinsistring = [[NSMutableAttributedString alloc] initWithString:@"隐私条款" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: KSCHEIGHT(15)],NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]}];

    yinsilabel.attributedText = yinsistring;
    
    UIButton *yinSiBtn = [[UIButton alloc] init];
    yinSiBtn.backgroundColor = [UIColor colorWithRed:172/255.0 green:95/255.0 blue:251/255.0 alpha:1.0];
    yinSiBtn.layer.shadowColor = [UIColor colorWithRed:173/255.0 green:172/255.0 blue:172/255.0 alpha:0.14].CGColor;
    yinSiBtn.layer.shadowOffset = CGSizeMake(0,2);
    yinSiBtn.layer.shadowOpacity = 1;
    yinSiBtn.layer.shadowRadius = 4;

    [yinSiBtn addTarget:self action:@selector(yinsiBClick) forControlEvents:UIControlEventTouchUpInside];
    CAGradientLayer *glT = [CAGradientLayer layer];
    glT.frame = CGRectMake(0,0,kSCRATIO(250),KSCHEIGHT(40));
    glT.startPoint = CGPointMake(0, 0);
    glT.endPoint = CGPointMake(1, 1);
    glT.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:65/255.0 blue:91/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:171/255.0 blue:102/255.0 alpha:1.0].CGColor];
    glT.locations = @[@(0.0),@(1.0)];
    ViewRadius(yinSiBtn, KSCHEIGHT(20));

    [yinSiBtn.layer addSublayer:glT];
    [yinSiBtn addSubview:yinsilabel];
    [self.view addSubview:yinSiBtn];
    
    
    [yinSiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(xieyiBtn.mas_bottom).mas_equalTo(KSCHEIGHT(20));
        make.width.mas_equalTo(kSCRATIO(250));
        make.height.mas_equalTo(KSCHEIGHT(40));
        
    }];
    [yinsilabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(yinSiBtn);
        make.centerY.mas_equalTo(yinSiBtn);
    }];
    
    
    
    
}
//服务协议点击方法
-(void)xieyiBClick{
    XyViewController *xieyiC = [[XyViewController alloc] init];
//    xieyiC.modalPresentationStyle = 0;
//    [self presentViewController:xieyiC animated:NO completion:^{
//
//    }];
    [self.navigationController pushViewController:xieyiC animated:NO];
}
//隐私条款点击方法
-(void)yinsiBClick{
    YSViewController *yinsiC = [[YSViewController alloc] init];
//    yinsiC.modalPresentationStyle = 0;
//    [self presentViewController:yinsiC animated:NO completion:^{
//
//    }];
    [self.navigationController pushViewController:yinsiC animated:NO];
}




@end
